Skip to content

fix test_named_agents by writing fake agent PATH to shell RC file#93

Merged
raine merged 4 commits intoraine:mainfrom
trentdavies:fix/fake-agent-path
Apr 3, 2026
Merged

fix test_named_agents by writing fake agent PATH to shell RC file#93
raine merged 4 commits intoraine:mainfrom
trentdavies:fix/fake-agent-path

Conversation

@trentdavies
Copy link
Copy Markdown
Contributor

Fix test_named_agents failures

The two TestKnownAgentAutoDetection tests in test_named_agents.py fail on machines that have Claude Code installed because the real claude binary runs instead of the fake test script.

Root cause

New tmux panes start a fresh shell that sources .zshrc/.bashrc. The fake agent binary was only added to PATH via tmux set-environment -g and the subprocess environment, but new pane shells don't inherit from either — they get PATH from their shell profile.

The passing tests in test_agents.py already handle this correctly by writing the fake PATH into a shell RC file. test_named_agents.py was missing this step, so I implemented it so just test on Mac succeeds.

Fix

Added _write_rc_with_fake_path() helper that writes export PATH="<fake-bin-dir>:$PATH" to the shell RC file, so new tmux panes find the fake agent binary first. Matches the existing pattern in test_agents.py.

Test plan

  • pytest tests/test_workmux_add/test_named_agents.py — both tests pass
  • just test — 328/328 pass, 0 failures

@raine raine force-pushed the fix/fake-agent-path branch from d9b64a1 to 9fcae27 Compare April 3, 2026 17:07
trentdavies and others added 3 commits April 3, 2026 20:07
New tmux panes start a fresh shell that sources .zshrc/.bashrc, so
fake agent binaries must be on PATH there — not just in the tmux
global environment. Matches the pattern used by test_agents.py.

Co-Authored-By: Trent Davies <trentdavies@users.noreply.github.com>
FakeAgentInstaller relied on each test manually writing the fake bin
directory to shell RC files so new tmux panes would find the fake agent.
Tests in test_named_agents.py and test_layouts.py forgot this step,
which could cause failures on machines where a real agent binary exists
in a system PATH directory (path_helper reorders PATH in login shells).

MuxEnvironment.__init__ now creates a shared fake-bin directory and
writes base RC files for all supported shells (bash, zsh, fish, nu)
that prepend it to PATH. FakeAgentInstaller.install() simply drops
scripts into this already-active directory.

Tests that wrote RC files only for PATH are simplified (removed the
manual writes). Tests that wrote additional RC content (aliases, env
vars, markers) now append instead of overwrite.
Use the existing SHELL_NAMES constant instead of a hardcoded list when
writing base RC files in MuxEnvironment.__init__.

Export SHELL in the wrapper script built by run_workmux_command() so
that WezTerm shell-parametrized tests propagate the configured shell
to the workmux subprocess. Previously configure_default_shell() set
env["SHELL"] but run_workmux_command() never exported it.
@raine raine force-pushed the fix/fake-agent-path branch from 9fcae27 to d74c735 Compare April 3, 2026 17:07
@raine raine merged commit 915e38a into raine:main Apr 3, 2026
@raine
Copy link
Copy Markdown
Owner

raine commented Apr 3, 2026

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants